var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2PlatformMgr = require("PlatformMgr");
var $2UIConfig = require("UIConfig");
var $2ccUtil = require("ccUtil");
var $2ServerConfig = require("ServerConfig");
var $2EventCenter = require("EventCenter");
var $2EventDefine = require("EventDefine");
var $2Platformconf = require("Platformconf");
var $2PhoneManager = require("PhoneManager");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_UIControl = /* */function (_cc$Component27) {
  function _ctor() {
    var _this98;
    babel_classCallCheck(this, _ctor);
    _this98 = _callSuper(this, _ctor, arguments);
    _this98.orderMuster = null;
    _this98._bannerRECT = null;
    return _this98;
  }
  babel_inherits(_ctor, _cc$Component27);
  return babel_createClass(_ctor, [{
    key: "bannerRECT",
    get() {
      null == this._bannerRECT && this.initBannerRECT();
      return this._bannerRECT;
    }
  }, {
    key: "initBannerRECT",
    value: function initBannerRECT() {
      var e = $2ccUtil.default.getChildByName(this.node, "banner");
      if (e) {
        this._bannerRECT = $2ccUtil.default.convertToWXRect(e);
      } else {
        console.log(' "banner" is endefine');
      }
    }
  }, {
    key: "initData",
    value: function initData() {
      var _this99 = this;
      if (this.node.getComponent(cc.Widget)) {
        this.node.getComponent(cc.Widget).enabled = true;
        this.node.getComponent(cc.Widget).updateAlignment();
      }
      0 == $2UIConfig.default.getInstance().inited && $2EventCenter.default.regisEventOnce($2EventDefine.default.EVENT_SERVERDATAENTER, this.initData, this);
      var e = $2UIConfig.default.getInstance()[$2Platformconf.ePlatformType[$2Platformconf.default.PlatformType]];
      if (!e) {
        return void console.error("UIConfig 缺少平台配置", $2Platformconf.ePlatformType[$2Platformconf.default.PlatformType]);
      }
      this.orderMuster = e[this.node.name];
      this.orderMuster = e[this.node.name];
      this.orderMuster || (this.orderMuster = {});
      var t = this;
      console.log(this.node.name, "   orderMuster：", this.orderMuster);
      var _loop3 = function _loop3() {
        if ("_BanerEvent" == _n44) {
          var _e44 = t.orderMuster._BanerEvent;
          if (_e44) {
            var _loop4 = function _loop4(_n45) {
              var o = _e44.timer[_n45];
              t.scheduleOnce(function () {
                if ("Hide" == _e44.event[_n45] || "Destroy" == _e44.event[_n45]) {
                  $2PlatformMgr.default.Instance()["banner" + _e44.event[_n45]](t.orderMuster._BannerId, t.bannerRECT);
                } else {
                  1 == t.orderMuster._BannerShow && $2PlatformMgr.default.Instance()["banner" + _e44.event[_n45]](t.orderMuster._BannerId, t.bannerRECT);
                }
              }, o);
            };
            for (var _n45 = 0; _n45 < _e44.timer.length; _n45++) {
              _loop4(_n45);
            }
          }
        } else {
          if ("_VideoID" == _n44) {
            return 0;
          }
          // continue
          if ("_NativeId" == _n44) {
            if (window.qg && (console.log("该界面需要显示原生广告" + t.orderMuster._NativeId), 1 == t.orderMuster._NativeShow)) {
              var _e45 = $2ccUtil.default.getChildByName(_this99.node, "nativeview");
              if (_e45) {
                _e45.active = true;
                $2PlatformMgr.default.Instance().showNativeAD(t.orderMuster._NativeId, _e45);
              } else {
                console.error("没有添加原生显示节点 nativeview");
              }
            }
          } else {
            if ("_" == _n44[0]) {
              return 0;
            }
            // continue
            if ("active" == _n44 || "zIndex" == _n44) {
              t.node[_n44] = t.orderMuster[_n44];
            } else if ("Component" == _n44) {
              for (var _e46 in t.orderMuster[_n44]) {
                var _o113 = t.node.getComponentsInChildren(_e46);
                if (_o113.length > 0) {
                  var _iterator5 = babel_createForOfIteratorHelper(_o113);
                  var _step5;
                  try {
                    for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
                      var _i24 = _step5.value;
                      for (var _o114 in t.orderMuster[_n44][_e46]) {
                        _i24[_o114] = t.orderMuster[_n44][_e46][_o114];
                      }
                    }
                  } catch (err) {
                    _iterator5.e(err);
                  } finally {
                    _iterator5.f();
                  }
                }
              }
            } else {
              var _e47 = $2ccUtil.default.getChildByName(t.node, _n44);
              if (null != _e47) {
                for (var _o115 in t.orderMuster[_n44]) {
                  if ("active" == _o115) {
                    var _i25 = true;
                    if ("boolean" == typeof t.orderMuster[_n44][_o115]) {
                      _i25 = t.orderMuster[_n44][_o115];
                    } else {
                      for (var _e48 in t.orderMuster[_n44][_o115]) {
                        if ("usertype" == _e48) {
                          _i25 = -1 !== t.orderMuster[_n44][_o115][_e48].indexOf($2PhoneManager.default.getInstance().userleve);
                        } else if (undefined === $2ServerConfig.default.getInstance().gameconfig.config[_e48] || $2ServerConfig.default.getInstance().gameconfig.config[_e48] !== t.orderMuster[_n44][_o115][_e48]) {
                          _i25 = false;
                          break;
                        }
                      }
                    }
                    _e47.active != _i25 && (_e47.active = _i25);
                  } else if ("Component" == _o115) {
                    for (var _i26 in t.orderMuster[_n44][_o115]) {
                      var _s9 = _e47.getComponentsInChildren(_i26);
                      if (_s9.length > 0) {
                        var _iterator6 = babel_createForOfIteratorHelper(_s9);
                        var _step6;
                        try {
                          for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
                            var _e49 = _step6.value;
                            for (var _s10 in t.orderMuster[_n44][_o115][_i26]) {
                              _e49[_s10] = t.orderMuster[_n44][_o115][_i26][_s10];
                            }
                          }
                        } catch (err) {
                          _iterator6.e(err);
                        } finally {
                          _iterator6.f();
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      };
      var _ret;
      for (var _n44 in this.orderMuster) {
        _ret = _loop3();
        if (_ret === 0) {
          continue;
        }
      }
    }
  }, {
    key: "onEnable",
    value: function onEnable() {
      this.initData();
    }
  }, {
    key: "onDisable",
    value: function onDisable() {
      $2EventCenter.default.removeEvent($2EventDefine.default.EVENT_SERVERDATAENTER, this.initData, this);
      if (this.orderMuster._BannerShow) {
        this.unscheduleAllCallbacks();
        console.log(this.name, "隐藏banner");
        $2PlatformMgr.default.Instance().bannerHide(this.orderMuster._BannerId);
      }
    }
  }]);
}(cc.Component);
def_UIControl = cc__decorate([ccp_ccclass], def_UIControl);
exports.default = def_UIControl;